package com.yufubao.api.controller.management.authorization;

import cn.dev33.satoken.annotation.SaIgnore;
import com.yufubao.framework.annotation.SystemLog;
import com.yufubao.framework.constant.NotesConstant;
import com.yufubao.framework.result.ResponseResult;
import com.yufubao.model.dto.management.authorization.ManagerLoginDto;
import com.yufubao.model.dto.management.authorization.ManagerRegisterDto;
import com.yufubao.model.vo.management.authorization.AdminManagerInfoVo;
import com.yufubao.model.vo.management.authorization.RoutersVo;
import com.yufubao.service.service.management.authorization.ManagementPowerService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

/**
 * @author 张一恒
 * @version 1.0
 * @description: 微信小程序后台管理系统权限api
 * @date 2024/9/2 20:04
 */
@Api("微信小程序后台管理系统权限api")
@RestController
@RequestMapping("/applet/management/manager/power")
public class ManagementPowerController {

    @Autowired
    private ManagementPowerService managementPowerService;


    /**
     * 注册
     */
    @Deprecated
    @ApiOperation(value = "注册", notes = NotesConstant.DEV)
    @RequestMapping(value = "/enroll", method = RequestMethod.POST)
    @SystemLog(info = "注册")
    public ResponseResult enroll(@RequestBody @Valid ManagerRegisterDto dto) {
        return managementPowerService.enroll(dto);
    }



    /**
     * 登录
     */
    @ApiOperation(value = "登录", notes = NotesConstant.DEV)
    @RequestMapping(value = "/login", method = RequestMethod.POST)
    @SystemLog(info = "登录")
    @SaIgnore
    public ResponseResult login(@RequestBody @Valid ManagerLoginDto dto) {
        return managementPowerService.login(dto);
    }

    /**
     * 查询人员权限信息
     * @return
     */
    @SystemLog(info = "查询人员权限信息")
    @ApiOperation(value = "查询人员权限信息", notes = NotesConstant.DEV)
    @RequestMapping(value = "/getInfo",method = RequestMethod.GET)
    public ResponseResult<AdminManagerInfoVo> getInfo(){
        return managementPowerService.getInfo();
    }


    /**
     * 查询人员菜单路由路径
     * @return
     */
    @SystemLog(info = "查询人员菜单路由路径")
    @ApiOperation(value = "查询人员菜单路由路径", notes = NotesConstant.DEV)
    @RequestMapping(value = "/getRouters",method = RequestMethod.GET)
    public ResponseResult<RoutersVo> getRouters(){
        return managementPowerService.getRouters();
    }
}
